package common;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class ItemImpl extends UnicastRemoteObject implements Item{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4184534278647838895L;
	private String name;
	private float price;
	private String owner;
	private int id;
	public ItemImpl(String owner, String name, float price)  throws RemoteException{
		this.name = name;
		this.price = price;
		this.owner = owner;
	}
	
	public ItemImpl(int id,String owner, String name, float price)  throws RemoteException{
		this.name = name;
		this.price = price;
		this.owner = owner;
		this.id = id;
	}
	
	public String getName() throws RemoteException{
		return name;
	}

	public float getPrice() throws RemoteException{
		return price;
	}

	public String getOwner() throws RemoteException{
		return owner;
	}

	public String getInfoStr() throws RemoteException{
		return name + " : " + price;
	}

	@Override
	public int getId() throws RemoteException {
		return id;
	}
	
	@Override
	public boolean equals(Object o)
	{
		Item i =(Item)o;
		try {
			if (this.getId() == i.getId())
				return true;
			else 
				return false;
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}
